#! /usr/bin/env python3
# coding = uft-8


class Solution(object):
    def reverse(self, x):
        res = 0
        neg = -1 if x < 0 else 1
        x = abs(x)
        while x > 0:
            t = x % 10
            x //= 10
            res *= 10
            res += t
        if res > 2**31 - 1:
            return 0
        return neg * res

s = Solution()
print(s.reverse(-1563847412))
